import http from './index.js'
/* 校验提交文章名字 */
const validataArticleName = (name)=>{
    return new Promise((resolve, reject) => {
       http.get("/api/article/validataarticlename",{
        params:{
            name
        }
    }).then((res)=>{
        resolve(res);
    })
})
}
/* 提交上传后的文件名字 */
const submitFileName = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/upload/submitfile",data).then((res)=>{
            resolve(res);
        })
    })
}
/* 提交文章 */
const addarticle = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/article/addarticle",data).then((res)=>{
            resolve(res);
        })
    })
}
/* 分页获取获取文章 */
const getarticle = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/article/getarticle",data).then((res)=>{
            resolve(res);
        })
    })
}
/* 分页获取草稿箱 */
const getdraft = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/article/getrecyclelist",data).then(res=>{
            resolve(res);
        })  
    })
}
/* 通过id获取文章 */
const getarticleByid=(id)=>{
    return new Promise((resolve, reject) => {
        http.get("/api/article/getarticlebyid",{
            params:{
                article_id:id
            }
        }).then(res=>{
            resolve(res);
        })
    })
}
/* 编辑文章 */
const edmitarticleapi =(data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/article/edmitarticle",data).then(res=>{
            resolve(res);
        })
    })
}
/* 编辑文章时修改文章名字 */
const editFileName = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/article/editfileName",data).then(res=>{
            resolve(res);
        })
    })
}
/* 置顶文章 */
const toToparticle =(data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/article/totoparticle",data).then(res=>{
            resolve(res);
        })
    })
}
/* 取消置顶文章 */
const cancelToparticle =(data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/article/canceltoparticle",data).then(res=>{
            resolve(res);
        })
    })
}
/* 删除文章 */
const deleteArticle = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/article/deleteArticle",data).then(res=>{
            resolve(res);
        })
    })
}
/* 搜索文章 */
const SearchArticle = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/article/getarticlebycondition",data).then(res=>{
            resolve(res);
        })
    })
}
const getposlistarticle =(data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/article/getposlistarticle",data).then(res=>{
            resolve(res);
        })
    })
}
const subposition = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/article/subposition",data).then(res=>{
            resolve(res);
        })
    })
}
const getAllowTotop = ()=>{
    return new Promise((resolve, reject) => {
        http.get("/api/article/getAllowTotop").then(res=>{
            resolve(res);
        })
    })
}
export {
    validataArticleName,
    addarticle,
    submitFileName,
    getarticle,
    getdraft,
    getarticleByid,
    edmitarticleapi,
    editFileName,
    toToparticle,
    cancelToparticle,
    deleteArticle,
    SearchArticle,
    getposlistarticle,
    subposition,
    getAllowTotop
}